<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<!-- BEGIN HEAD -->

<head>
    <meta charset="utf-8" />
    <title>添加配置项</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <link href="http://tv.speechb.com/lib/layui/css/layui.css" rel="stylesheet"/>
</head>
<body >
<!--
<script id="editor" type="text/plain" style="height: 150px;"/>

-->
<!-- Main content -->
<div style="margin-top: 30px;margin-right: 22px">
            <div class="layui-form" action="" style="max-width: 640px;margin: 0 auto">

                <div class="layui-form-item">
                    <label class="layui-form-label">名称</label>
                    <div class="layui-input-block">
                        <input id="name" type="text" name="name" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">内容</label>
                    <div class="layui-input-block">
                        <input id="content" type="text" name="content" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">描述</label>
                        <div class="layui-input-block">
                            <textarea id='desc' rows="10"name="desc" style="width:100%;max-height: 220px;overflow:auto;" class="layui-textarea" ></textarea>
                            <br/>

                        </div>
                    </div>
                </div>
                <div class="layui-form-item" style="text-align: center;">
                    <div class="layui-input-block">
                        <button id="submitBtn" class="layui-btn" lay-submit lay-filter="formDemo" style="margin: 0 auto">立即提交</button>
                    </div>
                </div>
            </div>

 <canvas id="catw" width="500" height="500" style="position: fixed; bottom: 0;right:0;"></canvas>
    <script src=" https://cdn.zhangxinxu.com/sp/demo/live2d/live2d/js/live2d.js"></script>
    <script type="text/javascript">
        loadlive2d("catw", " https://cdn.jsdelivr.net/gh/QiShaoXuan/live2DModel@1.0.0/live2d-widget-model-tororo/assets/tororo.model.json");
    </script>
</div>
<script type="text/javascript" charset="utf-8" src="http://tv.speechb.com/lib/layui/layui.js"></script>
<script src="http://tv.speechb.com/lib/superui/content/ui/global/jQuery/jquery.min.js"></script>
<script type="text/javascript">

    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            $("#submitBtn").attr("disabled","disabled")
            $.ajax({
                type : "POST",
                url : "/admin/config/publish",
                data: {
                    "key": data.field.name,
                    "value": data.field.content,
                    "desc":data.field.desc
                },
                success : function(result) {
                    $("#activation_code").html("");
                    var activationCode = $("#activation_code");
                    if(result.code==1) {
                        layer.msg('添加成功！', {icon: 1});
                        $('#name').val("");
                        $('#content').val("");
                        $('#desc').val("");
                    } else {
                        layer.msg('生成失败了！', {icon: 5});
                    }
                    $("#submitBtn").removeAttr("disabled");
                },
                error : function(e){
                    layer.msg('请求异常！', {icon: 5});
                    $("#submitBtn").removeAttr("disabled");
                }
            });
            return false;
        });
    });
    $(function(){

        $("#copy_code").click(function () {
            var copyText = $("#activation_code");//获取对象
            copyText .select();//选择
            document.execCommand("Copy");//执行复制

            layer.msg('复制成功', {icon: 1});
        });
    });

</script>
</body>

</html>